package com.ldc.wandroid.viewmodel;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import com.ldc.common.model.BaseModel;
import com.ldc.common.mvvm.ViewModelBase;
import com.ldc.common.net.Api2Request;
import com.ldc.wandroid.model.WeChatNumberModel;
import com.ldc.wandroid.server.ApiServer;

import java.util.List;

public class WeChatNumberViewModel extends ViewModelBase {
    private final MutableLiveData<BaseModel<List<WeChatNumberModel>>> resultData = new MutableLiveData<>();


    public LiveData<BaseModel<List<WeChatNumberModel>>> getResultData() {
        return resultData;
    }

    private final ApiServer apiServer;


    public WeChatNumberViewModel() {
        apiServer = Api2Request.getInstance().createServer(ApiServer.class);
    }


    public void getWechatNumberReq() {
        apiRequest(apiServer.getWechatNumber(), (status, result, throwable) -> {
            if (status) {
                resultData.setValue(result);
            } else {
                resultData.setValue(null);
            }
        });
    }
}
